#ifndef THREAD_SEARCH_LOGGER_TREE_H
#define THREAD_SEARCH_LOGGER_TREE_H

#include <wx/event.h>
#include <wx/treebase.h>

#include "ThreadSearchLoggerBase.h"

class wxString;
class wxWindow;
class wxPanel;
class wxTreeCtrl;
class wxTreeEvent;

class ThreadSearch;
class ThreadSearchView;
class ThreadSearchEvent;



class ThreadSearchLoggerTree : public wxEvtHandler, public ThreadSearchLoggerBase {
  public:

    ThreadSearchLoggerTree( ThreadSearchView& threadSearchView, ThreadSearch& threadSearchPlugin,
                            InsertIndexManager::eFileSorting fileSorting, wxPanel* pParent, long id );


    virtual ~ThreadSearchLoggerTree();


    virtual eLoggerTypes GetLoggerType() {return TypeTree;}


    virtual void OnThreadSearchEvent( const ThreadSearchEvent& event );


    virtual void Clear();


    virtual void OnSearchBegin( const ThreadSearchFindData& findData );


    virtual wxWindow* GetWindow();


    virtual void SetFocus();


    void OnLoggerTreeClick( wxTreeEvent& event );


    void OnLoggerTreeDoubleClick( wxTreeEvent& event );

  protected:

    bool GetFileLineFromTreeEvent( wxTreeEvent& event, wxString& filepath, long &line );


    bool hasResultLineForTreeItem( wxTreeItemId treeItemId );


    virtual void ConnectEvents( wxEvtHandler* pEvtHandler );


    virtual void DisconnectEvents( wxEvtHandler* pEvtHandler );


    void OnLoggerTreeContextualMenu( wxTreeEvent& event );


    void OnDeleteTreeItem( wxCommandEvent& event );


    void OnDeleteAllTreeItems( wxCommandEvent& event );


    void DeleteTreeItem( wxTreeItemId id );


    void DeleteTreeItems();

    wxTreeCtrl*  m_pTreeLog;
    bool         m_FirstItemProcessed; // Used to filter wxTree events and process useful ones only.
    wxTreeItemId m_FilesParentId;
    wxTreeItemId m_ToDeleteItemId;
};

#endif
